package com.util.cdb.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;
import org.springframework.util.StringUtils;

@Getter
@AllArgsConstructor
public enum DataSourceEnum {
    /**
     * 数据源常量
     */
    MYSQL("01", "MYSQL", "com.mysql.cj.jdbc.Driver"),
    HIVE("02", "HIVE", "org.apache.hive.jdbc.HiveDriver"),
    ;
    private final String dbType;
    private final String dbTypeName;
    private final String dbDriver;

    public static String getDbDriver(String dbType) {
        if (StringUtils.isEmpty(dbType)) {
            return null;
        }
        for (DataSourceEnum dataSourceEnum : values()) {
            if (dataSourceEnum.getDbType().equals(dbType)) {
                return dataSourceEnum.getDbDriver();
            }
        }
        return null;
    }
}
